
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Array类型 · gitbook电子书</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Date类型.html" />
    
    
    <link rel="prev" href="Object类型.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../使用/使用.html">
            
                <a href="../使用/使用.html">
            
                    
                    md语法 & gitbook使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../面试题/面试题.html">
            
                <a href="../面试题/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../面试题/html.html">
            
                <a href="../面试题/html.html">
            
                    
                    HTML
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../面试题/css.html">
            
                <a href="../面试题/css.html">
            
                    
                    CSS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../面试题/js.html">
            
                <a href="../面试题/js.html">
            
                    
                    JavaScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../面试题/vue.html">
            
                <a href="../面试题/vue.html">
            
                    
                    Vue
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../面试题/小程序.html">
            
                <a href="../面试题/小程序.html">
            
                    
                    小程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../面试题/编程题.html">
            
                <a href="../面试题/编程题.html">
            
                    
                    编程题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../html/">
            
                <a href="../html/">
            
                    
                    1. HTML
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../html/1.常用标签.html">
            
                <a href="../html/1.常用标签.html">
            
                    
                    1.1 常用标签
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../html/2.列表.html">
            
                <a href="../html/2.列表.html">
            
                    
                    1.2 列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../html/3.表单.html">
            
                <a href="../html/3.表单.html">
            
                    
                    1.3 表单属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../html/4.音频&视频.html">
            
                <a href="../html/4.音频&视频.html">
            
                    
                    1.4 ifame & audio & video
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../css/">
            
                <a href="../css/">
            
                    
                    2. CSS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../css/1.选择器.html">
            
                <a href="../css/1.选择器.html">
            
                    
                    2.1 选择器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../css/2.字体样式.html">
            
                <a href="../css/2.字体样式.html">
            
                    
                    2.2 字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../css/3.背景.html">
            
                <a href="../css/3.背景.html">
            
                    
                    2.3 背景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../css/4.盒子模型.html">
            
                <a href="../css/4.盒子模型.html">
            
                    
                    2.4 盒子模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../css/5.浮动.html">
            
                <a href="../css/5.浮动.html">
            
                    
                    2.5 浮动
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../css/6.定位和渐变.html">
            
                <a href="../css/6.定位和渐变.html">
            
                    
                    2.6 定位 & 渐变
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../css/7.过渡&变形.html">
            
                <a href="../css/7.过渡&变形.html">
            
                    
                    2.7 过渡 & 变形
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../css/8.动画.html">
            
                <a href="../css/8.动画.html">
            
                    
                    2.8 动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../css/9.滤镜.html">
            
                <a href="../css/9.滤镜.html">
            
                    
                    2.9 滤镜
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../css/10.布局.html">
            
                <a href="../css/10.布局.html">
            
                    
                    2.10 布局
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="./">
            
                <a href="./">
            
                    
                    3. JS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="数据类型.html">
            
                <a href="数据类型.html">
            
                    
                    3.1 数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="语句.html">
            
                <a href="语句.html">
            
                    
                    操作符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="操作符.html">
            
                <a href="操作符.html">
            
                    
                    语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="基本类型和引用类型的值.html">
            
                <a href="基本类型和引用类型的值.html">
            
                    
                    基本类型和引用类型的值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="执行环境及作用域.html">
            
                <a href="执行环境及作用域.html">
            
                    
                    执行环境及作用域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="垃圾收集.html">
            
                <a href="垃圾收集.html">
            
                    
                    垃圾收集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="Object类型.html">
            
                <a href="Object类型.html">
            
                    
                    Object类型
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.9" data-path="Array类型.html">
            
                <a href="Array类型.html">
            
                    
                    Array类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="Date类型.html">
            
                <a href="Date类型.html">
            
                    
                    Date类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="string&array.html">
            
                <a href="string&array.html">
            
                    
                    3.2 String & Array
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="date.html">
            
                <a href="date.html">
            
                    
                    3.3 Date类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.13" data-path="正则表达式.html">
            
                <a href="正则表达式.html">
            
                    
                    3.4 RegExp类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.14" data-path="global&math.html">
            
                <a href="global&math.html">
            
                    
                    3.5 Global对象 & Math对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.15" data-path="变量&作用域&垃圾收集.html">
            
                <a href="变量&作用域&垃圾收集.html">
            
                    
                    3.6 变量 & 作用域 & 垃圾收集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.16" data-path="流程控制&函数.html">
            
                <a href="流程控制&函数.html">
            
                    
                    3.7 流程控制 & 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.17" data-path="面向对象.html">
            
                <a href="面向对象.html">
            
                    
                    3.8 面向对象的程序设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.18" data-path="递归&冒泡&快速.html">
            
                <a href="递归&冒泡&快速.html">
            
                    
                    3.9 递归 & 冒泡 & 快速
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.19" data-path="定时器&防抖&节流.html">
            
                <a href="定时器&防抖&节流.html">
            
                    
                    3.10 定时器\防抖\节流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.20" data-path="DOM获取&DOM操作.html">
            
                <a href="DOM获取&DOM操作.html">
            
                    
                    3.11 DOM获取 & DOM操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.21" data-path="键盘事件&鼠标事件.html">
            
                <a href="键盘事件&鼠标事件.html">
            
                    
                    3.12 键盘事件 & 鼠标事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.22" data-path="事件冒泡&事件代理&事件绑定.html">
            
                <a href="事件冒泡&事件代理&事件绑定.html">
            
                    
                    3.13 事件冒泡\代理\绑定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.23" data-path="this指向.html">
            
                <a href="this指向.html">
            
                    
                    3.14 this指向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.24" data-path="Ajax&跨域.html">
            
                <a href="Ajax&跨域.html">
            
                    
                    3.15 Ajax & 跨域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.25" data-path="Bom.html">
            
                <a href="Bom.html">
            
                    
                    3.16 BOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.26" data-path="ES6.html">
            
                <a href="ES6.html">
            
                    
                    3.17 ES6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.27" data-path="js实例.html">
            
                <a href="js实例.html">
            
                    
                    3.18 js实例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    4. Vue
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../vue/1.基础.html">
            
                <a href="../vue/1.基础.html">
            
                    
                    4.1 基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../vue/2.生命周期.html">
            
                <a href="../vue/2.生命周期.html">
            
                    
                    4.2 生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../vue/3.vuex.html">
            
                <a href="../vue/3.vuex.html">
            
                    
                    4.3 vuex
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../vue/4.原理.html">
            
                <a href="../vue/4.原理.html">
            
                    
                    4.4 深入响应式原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../vue/5.组件.html">
            
                <a href="../vue/5.组件.html">
            
                    
                    4.5 组件进阶
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../vue/6.规模化.html">
            
                <a href="../vue/6.规模化.html">
            
                    
                    4.6 规模化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../vue/7.过渡&动画.html">
            
                <a href="../vue/7.过渡&动画.html">
            
                    
                    4.7 过渡 & 动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../vue/8.可复用性&组合.html">
            
                <a href="../vue/8.可复用性&组合.html">
            
                    
                    4.8 可复用性 & 组合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../vue/9.工具.html">
            
                <a href="../vue/9.工具.html">
            
                    
                    4.9 工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Node/">
            
                <a href="../Node/">
            
                    
                    5. Node
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../插件/">
            
                <a href="../插件/">
            
                    
                    插件
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Array类型</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="array&#x7C7B;&#x578B;">Array&#x7C7B;&#x578B;</h1>
<ol>
<li>&#x4F7F;&#x7528;Array&#x6784;&#x9020;&#x51FD;&#x6570;</li>
</ol>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>();
    <span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;&#x4E3A;20</span>
    <span class="hljs-keyword">var</span> colors = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(<span class="hljs-number">20</span>);
    <span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x6570;&#x7EC4;&#x7684;&#x5B50;&#x9879;</span>
    <span class="hljs-keyword">var</span> colors = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(<span class="hljs-string">&apos;red&apos;</span>,<span class="hljs-string">&apos;blue&apos;</span>,<span class="hljs-string">&apos;green&apos;</span>);
    <span class="hljs-comment">// &#x53EF;&#x7701;&#x7565;new&#x64CD;&#x4F5C;&#x7B26;</span>
    <span class="hljs-keyword">var</span> colors = <span class="hljs-built_in">Array</span>(<span class="hljs-number">3</span>);
    <span class="hljs-keyword">var</span> colors = <span class="hljs-built_in">Array</span>(<span class="hljs-string">&apos;bule&apos;</span>);
</code></pre>
<ol>
<li>&#x6570;&#x7EC4;&#x5B57;&#x9762;&#x91CF;&#x8868;&#x793A;&#x65B9;&#x6CD5;</li>
</ol>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>];
    <span class="hljs-keyword">var</span> names = [];
</code></pre>
<ol>
<li>&#x8BFB;&#x53D6; &amp; &#x957F;&#x5EA6;</li>
</ol>
<pre><code class="lang-js">    <span class="hljs-comment">// &#x8BFB;&#x53D6;(&#x4ECE;0&#x8D77;)</span>
    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>];
    <span class="hljs-built_in">console</span>.log(colors[<span class="hljs-number">0</span>]);          <span class="hljs-comment">// red</span>
    <span class="hljs-comment">// &#x5C5E;&#x6027;length(&#x4ECE;1&#x8D77;)</span>
    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>];
    <span class="hljs-built_in">console</span>.log(colors.length);      <span class="hljs-comment">// 3</span>
</code></pre>
<h3 id="1&#x68C0;&#x6D4B;&#x6570;&#x636E;">1.&#x68C0;&#x6D4B;&#x6570;&#x636E;</h3>
<h5 id="11-instanceof&#x64CD;&#x4F5C;&#x7B26;">1.1 instanceof&#x64CD;&#x4F5C;&#x7B26;</h5>
<pre><code class="lang-js">    <span class="hljs-keyword">if</span>(value <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Array</span>){
        <span class="hljs-comment">// &#x5BF9;&#x6570;&#x7EC4;&#x6267;&#x884C;&#x67D0;&#x4E9B;&#x64CD;&#x4F5C;</span>
    }
</code></pre>
<ul>
<li>&#x5982;&#x679C;&#x7F51;&#x9875;&#x4E2D;&#x5305;&#x542B;&#x591A;&#x4E2A;&#x6846;&#x67B6;&#xFF0C;&#x4F1A;&#x5B58;&#x5728;&#x4E24;&#x4E2A;&#x4EE5;&#x4E0A;&#x4E0D;&#x540C;&#x7684;&#x5168;&#x5C40;&#x6267;&#x884C;&#x73AF;&#x5883;&#xFF0C;&#x4ECE;&#x800C;&#x4F1A;&#x6709;&#x4E24;&#x4E2A;&#x4E0D;&#x540C;&#x7684;Array&#x6784;&#x9020;&#x51FD;&#x6570;</li>
</ul>
<h5 id="12-isarray&#x65B9;&#x6CD5;">1.2 isArray()&#x65B9;&#x6CD5;</h5>
<pre><code class="lang-js">    <span class="hljs-keyword">if</span>(<span class="hljs-built_in">Array</span>.isArray(value)){
        <span class="hljs-comment">// &#x5BF9;&#x6570;&#x7EC4;&#x6267;&#x884C;&#x67D0;&#x4E9B;&#x64CD;&#x4F5C;</span>
    }
</code></pre>
<h3 id="2-&#x8F6C;&#x6362;&#x65B9;&#x6CD5;">2. &#x8F6C;&#x6362;&#x65B9;&#x6CD5;</h3>
<ul>
<li>&#x5BF9;&#x8C61;&#x90FD;&#x5177;&#x6709;toLocaleString()&#x3001;toString()&#x548C;valueOf()</li>
<li>&#x8C03;&#x7528;&#x6570;&#x7EC4;&#x7684;toString()&#x65B9;&#x6CD5;&#x4F1A;&#x8FD4;&#x56DE;&#x7531;&#x6570;&#x7EC4;&#x4E2D;&#x6BCF;&#x4E2A;&#x503C;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x5F62;&#x5F0F;&#x62FC;&#x63A5;&#x800C;&#x6210;&#x7684;&#x4E00;&#x4E2A;&#x4EE5;&#x9017;&#x53F7;&#x5206;&#x9694;&#x7684;&#x5B57;&#x7B26;&#x4E32;</li>
<li>&#x8C03;&#x7528;valueOf()&#x8FD4;&#x56DE;&#x7684;&#x8FD8;&#x662F;&#x6570;&#x7EC4;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>];
    <span class="hljs-built_in">console</span>.log(colors.toString());     <span class="hljs-comment">// red,blue,green (String)</span>
    <span class="hljs-built_in">console</span>.log(colors.valueOf());      <span class="hljs-comment">// red,blue,green(Object)</span>
    <span class="hljs-built_in">console</span>.log(colors);                <span class="hljs-comment">// red,blue,green(Object)</span>
</code></pre>
<ul>
<li>join()&#x65B9;&#x6CD5;,&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x5206;&#x9694;&#x7B26;&#x6765;&#x6784;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>];
    <span class="hljs-built_in">console</span>.log(colors.join(<span class="hljs-string">&quot;,&quot;</span>));      <span class="hljs-comment">// red,green,blue(String)</span>
    <span class="hljs-built_in">console</span>.log(colors.join(<span class="hljs-string">&quot;||&quot;</span>))      <span class="hljs-comment">// red||green||blue(String)</span>
</code></pre>
<h3 id="3-&#x6808;&#x65B9;&#x6CD5;">3. &#x6808;&#x65B9;&#x6CD5;</h3>
<blockquote>
<p>&#x6808;&#x662F;&#x4E00;&#x79CD;LIFO&#xFF08;Last-In-First-Out&#xFF0C;<strong>&#x540E;&#x8FDB;&#x5148;&#x51FA;</strong>&#xFF09;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;</p>
</blockquote>
<ul>
<li>&#x6808;&#x4E2D;&#x9879;&#x7684;&#x63D2;&#x5165;&#xFF08;&#x53EB;&#x63A8;&#x5165;&#xFF09;&#xFF0C;&#x5BF9;&#x5E94;push()&#xFF0C;&#x8FD4;&#x56DE;&#x4FEE;&#x6539;&#x540E;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;</li>
<li>&#x6808;&#x4E2D;&#x9879;&#x7684;&#x79FB;&#x9664;&#xFF08;&#x53EB;&#x5F39;&#x51FA;&#xFF09;&#xFF0C;&#x5BF9;&#x5E94;pop()&#xFF0C;&#x8FD4;&#x56DE;&#x79FB;&#x9664;&#x7684;&#x9879;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>();
    <span class="hljs-keyword">var</span> count = colors.push(<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>);     <span class="hljs-comment">// &#x63A8;&#x5165;&#x4E24;&#x9879;</span>
    <span class="hljs-built_in">console</span>.log(count);                         <span class="hljs-comment">// 2</span>
    <span class="hljs-keyword">var</span> item = colors.pop();                    <span class="hljs-comment">// &#x5F39;&#x51FA;&#x4E00;&#x9879;</span>
    <span class="hljs-built_in">console</span>.log(item);                          <span class="hljs-comment">// black</span>
</code></pre>
<h3 id="4-&#x961F;&#x5217;&#x65B9;&#x6CD5;">4. &#x961F;&#x5217;&#x65B9;&#x6CD5;</h3>
<blockquote>
<p>&#x961F;&#x5217;&#x662F;&#x4E00;&#x79CD;FIFO&#xFF08;First-In-First-Out&#xFF0C;<strong>&#x5148;&#x8FDB;&#x5148;&#x51FA;</strong>&#xFF09;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;</p>
</blockquote>
<ul>
<li>&#x7ED3;&#x5408;&#x4F7F;&#x7528;shift()&#x548C;push()</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>();
    <span class="hljs-keyword">var</span> count = colors.push(<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>);
    <span class="hljs-keyword">var</span> item = colors.shift();                  <span class="hljs-comment">// &#x53D6;&#x5F97;&#x7B2C;&#x4E00;&#x9879;</span>
    <span class="hljs-built_in">console</span>.log(item);                          <span class="hljs-comment">// red</span>
</code></pre>
<ul>
<li>unshift()&#x80FD;&#x5728;&#x6570;&#x7EC4;&#x524D;&#x7AEF;&#x6DFB;&#x52A0;&#x4EFB;&#x610F;&#x9879;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;&#x65B0;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;</li>
</ul>
<h3 id="5-&#x91CD;&#x6392;&#x5E8F;&#x65B9;&#x6CD5;">5. &#x91CD;&#x6392;&#x5E8F;&#x65B9;&#x6CD5;</h3>
<ul>
<li>&#x7FFB;&#x8F6C;&#x6570;&#x7EC4;&#x9879;&#x7684;&#x987A;&#x5E8F;&#xFF1A;reverse()</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> values = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>];
    values.reverse();
    <span class="hljs-built_in">console</span>.log(values);     <span class="hljs-comment">// 5,4,3,2,1</span>
</code></pre>
<ul>
<li>&#x5347;&#x5E8F;&#x3001;&#x964D;&#x5E8F;&#xFF1A;sort()</li>
<li>&#x9ED8;&#x8BA4;&#x4E0B;&#xFF0C;sort()&#x4F1A;&#x8C03;&#x7528;&#x6BCF;&#x4E2A;&#x6570;&#x7EC4;&#x9879;&#x7684;toString()&#xFF0C;&#x7136;&#x540E;&#x6BD4;&#x8F83;&#x5F97;&#x5230;&#x7684;&#x5B57;&#x7B26;&#x4E32;</li>
<li>sort()&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x6BD4;&#x8F83;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;,&#x6BD4;&#x8F83;&#x51FD;&#x6570;&#x63A5;&#x53D7;&#x8FDE;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5982;&#x679C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x5E94;&#x8BE5;&#x4F4D;&#x4E8E;&#x7B2C;&#x4E8C;&#x4E2A;&#x4E4B;&#x524D;&#x5219;&#x8FD4;&#x56DE;&#x8D1F;&#x6570;&#x3002;&#x5982;&#x679C;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x76F8;&#x7B49;&#x8FD4;&#x56DE;0&#x3002;&#x5982;&#x679C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x5E94;&#x8BE5;&#x4F4D;&#x4E8E;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x4E4B;&#x540E;&#x5219;&#x8FD4;&#x56DE;&#x6B63;&#x6570;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> values = [<span class="hljs-number">0</span>,<span class="hljs-number">1</span>,<span class="hljs-number">5</span>,<span class="hljs-number">10</span>,<span class="hljs-number">15</span>];
    <span class="hljs-comment">// &#x9ED8;&#x8BA4;&#x60C5;&#x51B5;</span>
    values.sort();
    <span class="hljs-built_in">console</span>.log(values);     <span class="hljs-comment">// 0,1,10,15,5</span>
    <span class="hljs-comment">// &#x5347;&#x5E8F;</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">up</span>(<span class="hljs-params">font,back</span>)</span>{
        <span class="hljs-keyword">if</span>(font &lt; back){
            <span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
        }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(font &gt; back){
            <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
        }<span class="hljs-keyword">else</span>{
            <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
        }
    }
    <span class="hljs-built_in">console</span>.log(values.sort(up));    <span class="hljs-comment">// 0,1,5,10,15</span>
    <span class="hljs-comment">// &#x964D;&#x5E8F;</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">down</span>(<span class="hljs-params">font,back</span>)</span>{
        <span class="hljs-keyword">return</span> back - font
    }
    <span class="hljs-built_in">console</span>.log(values.sort(down));   <span class="hljs-comment">// 15,10,5,1,0</span>
</code></pre>
<h3 id="6-&#x64CD;&#x4F5C;&#x65B9;&#x6CD5;">6. &#x64CD;&#x4F5C;&#x65B9;&#x6CD5;</h3>
<ul>
<li>concat()&#x53EF;&#x4EE5;&#x57FA;&#x4E8E;&#x5F53;&#x524D;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x9879;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x6570;&#x7EC4;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>]
    <span class="hljs-keyword">var</span> colors2 = colors.concat(<span class="hljs-string">&quot;yellow&quot;</span>,[<span class="hljs-string">&quot;black&quot;</span>,<span class="hljs-string">&quot;brown&quot;</span>]);
    <span class="hljs-built_in">console</span>.log(colors);     <span class="hljs-comment">// red,green,blue</span>
    <span class="hljs-built_in">console</span>.log(colors2);    <span class="hljs-comment">// red,green,blue,yellow,black,brown</span>
</code></pre>
<ul>
<li>slice()&#x80FD;&#x591F;&#x57FA;&#x4E8E;&#x5F53;&#x524D;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x4E00;&#x6216;&#x591A;&#x4E2A;&#x9879;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x6570;&#x7EC4;</li>
<li>slice()&#x53C2;&#x6570;&#x4E2D;&#x6709;&#x4E00;&#x4E2A;&#x8D1F;&#x6570;&#xFF0C;&#x5219;&#x7528;&#x6570;&#x7EC4;&#x957F;&#x5EA6;&#x52A0;&#x4E0A;&#x8BE5;&#x6570;&#x6765;&#x786E;&#x5B9A;&#x76F8;&#x5E94;&#x7684;&#x4F4D;&#x7F6E;&#x3002;5&#x9879;&#x7684;&#x6570;&#x7EC4;&#x8C03;&#x7528;slice(-2,-1)&#x4E0E;&#x8C03;&#x7528;slice(3,4)&#x6548;&#x679C;&#x4E00;&#x6837;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>,<span class="hljs-string">&quot;yellow&quot;</span>,<span class="hljs-string">&quot;purple&quot;</span>];
    <span class="hljs-keyword">var</span> colors2 = colors.slice(<span class="hljs-number">1</span>);
    <span class="hljs-keyword">var</span> colors3 = colors.slice(<span class="hljs-number">1</span>,<span class="hljs-number">4</span>);
    <span class="hljs-built_in">console</span>.log(colors2);      <span class="hljs-comment">// green,blue,yellow,purple</span>
    <span class="hljs-built_in">console</span>.log(colors3);      <span class="hljs-comment">// green,blue,yellow</span>
</code></pre>
<ul>
<li>splice()&#x4E3B;&#x8981;&#x662F;&#x5411;&#x6570;&#x7EC4;&#x4E2D;&#x90E8;&#x63D2;&#x5165;&#x9879;<ul>
<li>&#x5220;&#x9664;&#xFF1A;&#x53EF;&#x4EE5;&#x5220;&#x9664;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x9879;&#x3002;2&#x4E2A;&#x53C2;&#x6570;&#xFF1A;&#x8981;&#x5220;&#x9664;&#x7684;&#x7B2C;&#x4E00;&#x9879;&#x4F4D;&#x7F6E;&#x548C;&#x8981;&#x5220;&#x9664;&#x7684;&#x9879;&#x6570;&#x3002;<code>splice(0,2)</code>&#x5220;&#x9664;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x524D;&#x4E24;&#x9879;</li>
<li>&#x63D2;&#x5165;&#xFF1A;&#x53EF;&#x4EE5;&#x5411;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x9879;&#x3002;3&#x4E2A;&#x53C2;&#x6570;&#xFF1B;&#x8D77;&#x59CB;&#x4F4D;&#x7F6E;&#x3001;&#x8981;&#x5220;&#x9664;&#x7684;&#x9879;&#x6570;&#x3001;&#x63D2;&#x5165;&#x7684;&#x9879;&#x3002;<code>splice(2,0,&quot;red&quot;,&quot;green&quot;)</code>,&#x4F1A;&#x4ECE;&#x5F53;&#x524D;&#x6570;&#x7EC4;&#x7684;&#x4F4D;&#x7F6E;2&#x5F00;&#x59CB;&#x63D2;&#x5165;&quot;red&quot;&#x548C;&quot;green&quot;</li>
<li>&#x66FF;&#x6362;&#xFF1A;&#x53EF;&#x4EE5;&#x5411;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x9879;&#xFF0C;&#x4E14;&#x540C;&#x65F6;&#x5220;&#x9664;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x9879;&#x3002;<code>splice(2,1,&quot;red&quot;,&quot;green&quot;)</code>&#x4F1A;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6570;&#x7EC4;&#x4F4D;&#x7F6E;2&#x7684;&#x9879;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x4ECE;&#x4F4D;&#x7F6E;2&#x5F00;&#x59CB;&#x63D2;&#x5165;&quot;red&quot;,&quot;green&quot;</li>
</ul>
</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> colors = [<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;green&quot;</span>,<span class="hljs-string">&quot;blue&quot;</span>];
    <span class="hljs-comment">// &#x5220;&#x9664;&#x7B2C;&#x4E00;&#x9879;</span>
    <span class="hljs-keyword">var</span> removed = colors.splice(<span class="hljs-number">0</span>,<span class="hljs-number">1</span>);     
    <span class="hljs-built_in">console</span>.log(colors);         <span class="hljs-comment">// green,blue</span>
    <span class="hljs-built_in">console</span>.log(removed);        <span class="hljs-comment">// [red]</span>
    <span class="hljs-comment">// &#x4ECE;&#x4F4D;&#x7F6E;1&#x5F00;&#x59CB;&#x63D2;&#x5165;&#x4E24;&#x9879;</span>
    removed = colors.splice(<span class="hljs-number">1</span>,<span class="hljs-number">0</span>,<span class="hljs-string">&quot;yellow&quot;</span>,<span class="hljs-string">&quot;orange&quot;</span>);
    <span class="hljs-built_in">console</span>.log(colors);        <span class="hljs-comment">// green,yellow,orange,blue</span>
    <span class="hljs-built_in">console</span>.log(removed);       <span class="hljs-comment">// []</span>
    <span class="hljs-comment">// &#x63D2;&#x5165;&#x4E24;&#x9879;&#xFF0C;&#x5220;&#x9664;&#x4E00;&#x9879;</span>
    removed = colors.splice(<span class="hljs-number">1</span>,<span class="hljs-number">1</span>,<span class="hljs-string">&quot;red&quot;</span>,<span class="hljs-string">&quot;purple&quot;</span>);
    <span class="hljs-built_in">console</span>.log(colors);        <span class="hljs-comment">// green,red,purple,orange,blue</span>
    <span class="hljs-built_in">console</span>.log(removed);       <span class="hljs-comment">// [yellow]</span>
</code></pre>
<h3 id="7-&#x4F4D;&#x7F6E;&#x65B9;&#x6CD5;">7. &#x4F4D;&#x7F6E;&#x65B9;&#x6CD5;</h3>
<ul>
<li>indexOf()&#x4ECE;&#x5934;&#x5F00;&#x59CB;&#x67E5;&#x627E;</li>
<li>lastIndexOf()&#x4ECE;&#x672B;&#x5C3E;&#x5F00;&#x59CB;&#x67E5;&#x627E;</li>
<li>&#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#x90FD;&#x8FD4;&#x56DE;&#x8981;&#x67E5;&#x627E;&#x9879;&#x5728;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x6CA1;&#x627E;&#x5230;&#x8FD4;&#x56DE;-1</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> num = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">4</span>,<span class="hljs-number">3</span>,<span class="hljs-number">2</span>,<span class="hljs-number">1</span>];
    <span class="hljs-built_in">console</span>.log(num.indexOf(<span class="hljs-number">4</span>));      <span class="hljs-comment">// 3</span>
    <span class="hljs-built_in">console</span>.log(num.lastIndexOf(<span class="hljs-number">4</span>));  <span class="hljs-comment">// 5</span>
    <span class="hljs-built_in">console</span>.log(num.indexOf(<span class="hljs-number">4</span>,<span class="hljs-number">4</span>));    <span class="hljs-comment">// 5</span>
    <span class="hljs-built_in">console</span>.log(num.lastIndexOf(<span class="hljs-number">4</span>,<span class="hljs-number">4</span>));<span class="hljs-comment">// 3</span>
</code></pre>
<h3 id="8-&#x8FED;&#x4EE3;&#x65B9;&#x6CD5;">8. &#x8FED;&#x4EE3;&#x65B9;&#x6CD5;</h3>
<blockquote>
<p>5&#x4E2A;&#x8FED;&#x4EE3;&#x65B9;&#x6CD5;&#x3002;&#x6BCF;&#x4E2A;&#x65B9;&#x6CD5;&#x90FD;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#xFF1B;&#x8981;&#x5728;&#x6BCF;&#x4E00;&#x9879;&#x4E0A;&#x8FD0;&#x884C;&#x7684;&#x51FD;&#x6570;&#x548C;&#x8FD0;&#x884C;&#x8BE5;&#x51FD;&#x6570;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;--&#x5F71;&#x54CD;this&#x7684;&#x503C;</p>
</blockquote>
<table>
<thead>
<tr>
<th style="text-align:left">&#x65B9;&#x6CD5;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">every()</td>
<td style="text-align:left">&#x8BE5;&#x51FD;&#x6570;&#x5BF9;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x8FD4;&#x56DE;true&#xFF0C;&#x5219;&#x8FD4;&#x56DE;true</td>
</tr>
<tr>
<td style="text-align:left">some()</td>
<td style="text-align:left">&#x8BE5;&#x51FD;&#x6570;&#x5BF9;&#x4EFB;&#x4E00;&#x9879;&#x8FD4;&#x56DE;true&#xFF0C;&#x5219;&#x8FD4;&#x56DE;true</td>
</tr>
<tr>
<td style="text-align:left">filter()</td>
<td style="text-align:left">&#x8FD4;&#x56DE;&#x8BE5;&#x51FD;&#x6570;&#x4F1A;&#x8FD4;&#x56DE;true&#x7684;&#x9879;&#x7EC4;&#x6210;&#x7684;&#x6570;&#x7EC4;</td>
</tr>
<tr>
<td style="text-align:left">map()</td>
<td style="text-align:left">&#x8FD4;&#x56DE;&#x6BCF;&#x6B21;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x7684;&#x7ED3;&#x679C;&#x7EC4;&#x6210;&#x7684;&#x6570;&#x7EC4;</td>
</tr>
<tr>
<td style="text-align:left">forEach()</td>
<td style="text-align:left">&#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;</td>
</tr>
</tbody>
</table>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> arr = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">4</span>,<span class="hljs-number">3</span>,<span class="hljs-number">2</span>,<span class="hljs-number">1</span>];
    <span class="hljs-comment">// 1.every()</span>
    <span class="hljs-keyword">var</span> every = arr.every(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item,index,array</span>)</span>{
        <span class="hljs-keyword">return</span> (item &gt; <span class="hljs-number">2</span>);
    })
    <span class="hljs-built_in">console</span>.log(every);      <span class="hljs-comment">// false</span>
    <span class="hljs-comment">// 2.some()</span>
    <span class="hljs-keyword">var</span> some = arr.some(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item,index,array</span>)</span>{
        <span class="hljs-keyword">return</span> (item &gt; <span class="hljs-number">2</span>);
    })
    <span class="hljs-built_in">console</span>.log(some);       <span class="hljs-comment">// true</span>
    <span class="hljs-comment">// 3.filter()</span>
    <span class="hljs-keyword">var</span> filter = arr.filter(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item,index,array</span>)</span>{
        <span class="hljs-keyword">return</span> (item &gt; <span class="hljs-number">2</span>);
    })
    <span class="hljs-built_in">console</span>.log(filter);     <span class="hljs-comment">// [3,4,5,4,3]</span>
    <span class="hljs-comment">// 4.map()</span>
    <span class="hljs-keyword">var</span> map = arr.map(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item,index,array</span>)</span>{
        <span class="hljs-keyword">return</span> item*<span class="hljs-number">2</span>;
    })
    <span class="hljs-built_in">console</span>.log(map);        <span class="hljs-comment">// [2,4,6,8,10,8,6,4,2]</span>
    <span class="hljs-comment">// 5.forEach()</span>
    <span class="hljs-keyword">var</span> forEach = arr.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item,index,array</span>)</span>{
        <span class="hljs-comment">// &#x6267;&#x884C;&#x67D0;&#x4E9B;&#x64CD;&#x4F5C;</span>
    })
</code></pre>
<h3 id="9-&#x5F52;&#x5E76;&#x65B9;&#x6CD5;">9. &#x5F52;&#x5E76;&#x65B9;&#x6CD5;</h3>
<ul>
<li>reduce()&#x4ECE;&#x6570;&#x7EC4;&#x7684;&#x7B2C;&#x4E00;&#x9879;&#x5F00;&#x59CB;</li>
<li>reduceRight()&#x4ECE;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x540E;&#x4E00;&#x9879;&#x5F00;&#x59CB;</li>
<li>&#x90FD;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#xFF1B;&#x4E00;&#x4E2A;&#x5728;&#x6BCF;&#x4E00;&#x9879;&#x4E0A;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x548C;&#x4F5C;&#x4E3A;&#x5F52;&#x5E76;&#x57FA;&#x7840;&#x7684;&#x521D;&#x59CB;&#x503C;</li>
<li>&#x4F20;&#x5165;&#x7684;&#x51FD;&#x6570;&#x63A5;&#x53D7;4&#x4E2A;&#x53C2;&#x6570;&#xFF1A;&#x524D;&#x4E00;&#x4E2A;&#x503C;&#x3001;&#x5F53;&#x524D;&#x503C;&#x3001;&#x9879;&#x7684;&#x7D22;&#x5F15;&#x548C;&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</li>
</ul>
<pre><code class="lang-js">    <span class="hljs-keyword">var</span> values = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>];
    <span class="hljs-keyword">var</span> sum = values.reduce(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">prev,cur,index,array</span>)</span>{
        <span class="hljs-keyword">return</span> prev + cur;
    });
    <span class="hljs-built_in">console</span>.log(sum);      <span class="hljs-comment">// 15</span>
</code></pre>
<ul>
<li>&#x7B2C;&#x4E00;&#x6B21;&#x6267;&#x884C;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#xFF0C;prev&#x662F;1&#xFF0C;cur&#x662F;2&#x3002;&#x7B2C;&#x4E8C;&#x6B21;&#xFF0C;prev&#x662F;3&#xFF0C;cur&#x662F;3</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Object类型.html" class="navigation navigation-prev " aria-label="Previous page: Object类型">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Date类型.html" class="navigation navigation-next " aria-label="Next page: Date类型">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Array类型","level":"1.5.9","depth":2,"next":{"title":"Date类型","level":"1.5.10","depth":2,"path":"JS/Date类型.md","ref":"JS/Date类型.md","articles":[]},"previous":{"title":"Object类型","level":"1.5.8","depth":2,"path":"JS/Object类型.md","ref":"JS/Object类型.md","articles":[]},"dir":"ltr"},"config":{"plugins":["toggle-chapters","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"toggle-chapters":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"gitbook电子书","gitbook":"*","description":"记录前端相关的知识点以及一些示例的demo"},"file":{"path":"JS/Array类型.md","mtime":"2019-04-11T09:14:45.005Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-06T08:37:43.293Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

